<template>
    <div class="user">
        <basic-container>
            <avue-crud
                    v-model="form"
                    v-model:page="page"
                    v-model:search="searchForm"
                    :permission="getPermission"
                    v-bind="bindVal"
                    v-on="onEvent"
                    :option="option"
                    :data="tableData"
                    :before-open="beforeOpen"
            >
              <template #menu="scope">
                <el-button link type="primary"  icon="el-icon-edit" @click="openDesign(scope.row, scope.index)">证书配置</el-button>
                <el-button link type="primary"  icon="el-icon-edit" @click="createData(scope.row, scope.index)">证书用户管理</el-button>
                <el-button link type="primary"  icon="el-icon-edit" @click="configData(scope.row, scope.index)">证书用户管理配置</el-button>
<!--                <el-button link type="primary"  icon="el-icon-edit" @click="createLicense(scope.row, scope.index)">批量生成</el-button>-->
              </template>
            </avue-crud>

        </basic-container>

        <import-upload :base-url="pageConfig.url" :model-name="pageConfig.name" v-model="importDialogVisible"  ></import-upload>

    </div>
</template>

<script>
    import curdMixin from '@/framework-core/mixins/crud';
    import {tableOption} from "./index";
    import ImportUpload from "@/framework-core/components/upload/index.vue";
    import { randomId } from "@smallwei/avue";


    export default {
      name: "form_license",
      mixins: [curdMixin],
      components: {ImportUpload},
      data() {
        return {
          pageConfig: {name: "表单证书", "url": "/license/formLicense"},
          searchForm: {},
          loading: false,
          option: tableOption
        };
      },
      computed: {
        ...mapState({
          permissions: (state) => state.user.permission,
        })

      },
      created() {
        this.myinitOptionDict();
        this.init();
      },
      methods: {
        init() {
        },
        saveBefor(row) {
          if (row.id) {
            return
          }
          row.modelDB = "test";
          row.modelTable = "license_" + randomId(5);
        },
        getPermission: function (key, row, index) {
          return this.getCommPermission(key, row, index);
        },
        openDesign( row, index) {
          const routeData = this.$router.resolve({
            path: "/license/design",
            query: {
              formId: row.id,
            }
          })
          window.open(routeData.href, '_blank');
        },
        createData( row, index){
          const routeData = this.$router.resolve({
            path: "/query/preview",
            query: {
              app: row.appCode,
            }
          })
          window.open(routeData.href, '_blank');
        },
        configData( row, index){
          const routeData = this.$router.resolve({
            path: "/form/formqueryapp/index",
            query: {
              app: row.appCode,
            }
          })
          window.open(routeData.href, '_blank');
        },

        createLicense( row, index){

        },
      }
    };
</script>
<style lang="scss">

</style>
